﻿namespace _02.BankExersice.Accounts
{
    using System;
    using _02.BankExersice.Customers;

    public class Deposit : Account, IWithDrawable
    {
        public Deposit(Customer customer)
            : base(customer)
        {
        }

        public Deposit(Customer customer, decimal interestRate, decimal balance)
            : base(customer, interestRate, balance)
        {
        }

        public void WithDraw(decimal amount)
        {
            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException("Amount must be positive number!");
            }
            else if (amount > this.Balance)
            {
                throw new ArgumentException("Amount must be smaller than account balance!");
            }

            this.Balance -= amount;
        }

        public override decimal CalculateInterestAmount(int numberOfMonths)
        {
            if (this.Balance >= 1000)
            {
                return base.CalculateInterestAmount(numberOfMonths);
            }
            else
            {
                return 0;
            }
        }
    }
}
